var inputCreditCardsCount = 1;

$(function() {
	var offset = $("#fixed").offset();
	$(window).scroll(function() {
		if ($(window).scrollTop() > offset.top) {
			$("#fixed").stop().animate({ marginTop: 0 });
		} else {
			$("#fixed").stop().animate({ marginTop: $(window).scrollTop() });
		};
	});
});

function checkAgreeTermsAndConditions() {
	if($("#agree").attr("checked") != 'checked') { 
        window.alert('Please read and agree to the following Terms And Conditions!');
        return false;
    }
}

function checkBilling() {
	if($("#agree1").attr("checked") != 'checked') { 
        window.alert('Please agree with terms and conditions!');
        return false;
    }
	if($("#agree2").attr("checked") != 'checked') { 
        window.alert('Please agree with terms and conditions!');
        return false;
    }
}

function signupCheck() {
	var inputs = [ $('input[name="input"]') ];
	if($("#signupAgree").attr("checked") != 'checked') { 
		$("#LeftColumn").css({"color" : "gray"});
		$("#RightColumn").css({"color" : "gray"});
		$.each(inputs, function(i, entry) {
			entry.attr("readonly", "readonly");
		});
    } else {
    	$("#LeftColumn").css({"color" : "black"});
		$("#RightColumn").css({"color" : "black"});
		$.each(inputs, function(i, entry) {
			entry.attr("readonly", null);
		});
    }
}
function signupCheckSubmit() {
	if($("#signupAgree").attr("checked") != 'checked') { 
        window.alert('Please read and agree to the following sales agreement!');
        return false;
    }
}

/*var addOneMoreCreditCard = function(){
	var appendText = "";
	var cardType = $("#CardType", "#creditCards").val();
	var cardNumber = $("#CardNumber", "#creditCards").val();
	
	var cardTypes = ["", "1", "2", "3", "4", "5"];
	
	appendText += '<div class="control-group">';
	appendText += '<label class="control-label" for="CardType' + inputCreditCardsCount +'">Card type</label>';
	appendText += '<div class="controls">';
	appendText += '<select id="CardType' + inputCreditCardsCount + '" disabled>';
	
	$.each(cardTypes, function(i, type){
		appendText += '<option value="' + i + '"';
		if (cardType == i)
			appendText += 'selected="selected"';
		appendText += '>' + type + '</option>';
	});
	
	appendText += '</select>';
	appendText += '</div>';
	appendText += '</div>';
	appendText += '<div class="control-group">';
	appendText += '<label class="control-label" for="CellNumber' + inputCreditCardsCount + '">Card number</label>';
	appendText += '<div class="controls">';
	appendText += '<input type="text" id="CellNumber' + inputCreditCardsCount + '" placeholder="Card number..." value="' + cardNumber + '" disabled>';
	appendText += '</div>';
	appendText += '</div>';
	
	$("#creditCards").append(appendText);
	inputCreditCardsCount++;
};*/

var removeCreditCardFromMyAccount = function(thisElem){
	thisElem.parents("div.control-group").fadeOut(200, function(){
		thisElem.parents("div.control-group").remove();
	});
};